VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Senior Users and Administrator Access:"
   ClientHeight    =   4365
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7155
   LinkTopic       =   "Form1"
   ScaleHeight     =   4365
   ScaleWidth      =   7155
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   120
      Locked          =   -1  'True
      MultiLine       =   -1  'True
      TabIndex        =   3
      Text            =   "SeniorUpdate.frx":0000
      Top             =   3840
      Width           =   6975
   End
   Begin VB.ListBox List1 
      Height          =   2985
      Left            =   120
      TabIndex        =   1
      Top             =   720
      Width           =   6975
   End
   Begin VB.Label lblCount 
      Height          =   255
      Left            =   1080
      TabIndex        =   2
      Top             =   120
      Width           =   2535
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "Processing"
      Height          =   195
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   780
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
    Dim AdoRs As New ADODB.Recordset
    Dim AdoCon As New ADODB.Connection
    Dim sSQL As String
    Dim UserCnt As Long
    Dim AdoInsSQl As String
    Dim Adors2 As New ADODB.Recordset
    Dim objSettings As New clsSettings
    Dim sBuni_Code As String ' business units
    
    On Error GoTo ErrHandler:
    
    AdoCon.Open objSettings.ConnectString '"Provider=SQLOLEDB.1;Data Source=SQL02;User ID=keytax; Password=m1ndk3y;Initial Catalog=keytax"
    
    Me.Show
    If AdoCon.State = 1 Then

        'sSQL = "select dcd.use_id from dir_users du,dir_contact_details dcd where "
        'sSQL = sSQL & " du.buni_code = 'LCB' and du.cslev_id = 3 and dcd.use_id = du.use_id order by du.use_id"
        
        '#Stmt to retrieve all the senior users in all business units
        sSQL = "select * from dir_users du,dir_company_security_levels dc where "
        sSQL = sSQL & " (dc.role_description='Senior User'"
        'Tina: added for Administrator role - 2006/01/30
        sSQL = sSQL & " or dc.role_description='Administrator')"
        sSQL = sSQL & " and du.cslev_id = dc.cslev_id"
        
        AdoRs.Open sSQL, AdoCon, adOpenKeyset, adLockReadOnly
        If Not AdoRs.EOF Then
            Do
                
                AdoInsSQl = "Select 'Insert into dir_load_for_users values(' + cast(use_id as varchar) + ', " & AdoRs!use_id & " );' from dir_users where buni_code = '" & AdoRs!buni_code & "'"
                DoEvents
                Adors2.Open AdoInsSQl, AdoCon, adOpenStatic
                If Not Adors2.EOF Then
                    
                    Do

                        On Error Resume Next
                        AdoCon.Execute Trim(Adors2(0).Value)
                        Debug.Print Adors2(0).Value
                        If Err = 0 Then
                            'Debug.Print "Cool: " & Trim(Adors2(0).Value)
                            Me.List1.AddItem Trim(Adors2(0).Value)
                        Else
                            Err.Clear
                            On Error GoTo ErrHandler:
                        End If
                        DoEvents
                        UserCnt = UserCnt + 1
                        lblCount = UserCnt
                        DoEvents
                        Adors2.MoveNext
                    Loop Until Adors2.EOF
                    Adors2.Close
                End If
                DoEvents
                AdoRs.MoveNext
            Loop Until AdoRs.EOF
        End If
    End If
    DoEvents
    Set AdoRs = Nothing
    Set AdoCon = Nothing
    Set Adors2 = Nothing
    End
    Exit Sub
ErrHandler:
    Set AdoRs = Nothing
    Set AdoCon = Nothing
    Set Adors2 = Nothing
    End
End Sub

